package com.zdsoft.finance.product.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.zdsoft.finance.base.service.impl.BaseServiceImpl;
import com.zdsoft.finance.common.base.CustomRepository;
import com.zdsoft.finance.common.exception.BusinessException;
import com.zdsoft.finance.product.entity.ProductFunction;
import com.zdsoft.finance.product.repository.ProductFunctionRepository;
import com.zdsoft.finance.product.service.ProductFunctionService;
import com.zdsoft.framework.core.common.util.ObjectHelper;

/**
 * 产品功能操作实现
 * @author longwei
 * @date 2016/11/22
 * @version 1.0
 */
@Service("productFunctionService")
public class ProductFunctionServiceImpl extends BaseServiceImpl<ProductFunction, CustomRepository<ProductFunction,String>> implements ProductFunctionService{

	@Autowired
	private ProductFunctionRepository productFunctionRepository;
	
	@Override
	public Page<ProductFunction> queryByCons(ProductFunction productFunction, Pageable pageable) {
		return productFunctionRepository.queryByCons(productFunction, pageable);
	}

	@Override
	public ProductFunction findByFunctionCdAndProductCode(String functionCd, String code) throws BusinessException {
		if(ObjectHelper.isEmpty(functionCd)){
			throw new BusinessException("传入functionCd为空");
		}
		if(ObjectHelper.isEmpty(code)){
			throw new BusinessException("传入产品编号为空");
		}
		return productFunctionRepository.findByFunctionCdAndProductCode(functionCd, code);
	}

	

}
